//
//  SYSuggestionViewController.m
//  BSHOUYIFANG
//
//  Created by Zhoudi on 15/8/22.
//  Copyright (c) 2015年 CYB. All rights reserved.
//

#import "SYSuggestionViewController.h"
#import "Header.h"
@interface SYSuggestionViewController ()<UITextFieldDelegate>
@property (nonatomic,strong)UIScrollView * mainScrollView;
@property (nonatomic,strong)UITextView * mainTextView;

@end

@implementation SYSuggestionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationItem];
    _mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self creatTextView];
    [self navigationItemTitleColor];
    self.view.backgroundColor = [UIColor lightGrayColor];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH/12)];
    label.text =@"请输入反馈意见";
    label.font =[UIFont systemFontOfSize:15];
    label.backgroundColor = kMColor(240, 240, 240, 1);
    [_mainScrollView addSubview:label];
    [self.view addSubview:_mainScrollView];
    // Do any additional setup after loading the view.
}
- (void)navigationItemTitleColor
{
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    [customLab setTextColor:[UIColor whiteColor]];
    [customLab setText:@"意见反馈"];
    customLab.textAlignment = NSTextAlignmentCenter;
    customLab.font = [UIFont boldSystemFontOfSize:20];
    self.navigationItem.titleView = customLab;
}
- (void)setNavigationItem
{
    self.navigationItem.title =@"意见反馈";
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithTitle:@"发送" style:UIBarButtonItemStylePlain target:self action:@selector(sendSuggestion:)];
    self.navigationItem.rightBarButtonItem =rightBarButton;
    rightBarButton.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem.style =UIBarButtonItemStylePlain;
    self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"table_cell_Indicatorleft@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
}

- (void)creatTextView
{
    _mainTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 25, SCREEN_WIDTH, SCREEN_HEIGHT/2)];
    _mainTextView.font = [UIFont systemFontOfSize:17];
    [_mainTextView becomeFirstResponder];
    [_mainScrollView addSubview:_mainTextView];
}

- (void)sendSuggestion:(UIButton*)sender
{
    if ([_mainTextView.text length] == 0) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 -40, SCREEN_HEIGHT/2, SCREEN_WIDTH/4.5, 20)];
        label.text =@"请填写内容";
        label.backgroundColor = [UIColor blackColor];
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:13];
        [self.view addSubview:label];
    }else{
        self.showBlock();
        [_mainTextView endEditing:YES];
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)backAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
